﻿// -------------------------------------------------------------------------
//    @FileName         :    NFCityPlayer.h
//    @Author           :    Gao.Yi
//    @Date             :    2025-09-12
//    @Email			:    445267987@qq.com
//    @Module           :    NFCityPlayer
//    @Desc             :
//
// -------------------------------------------------------------------------

#pragma once

#include "NFCityPlayerBattleExt.h"
#include "NFCityPlayerBuffExt.h"
#include "NFCityPlayerDanceExt.h"
#include "NFCityPlayerEscortAgent.h"
#include "NFCityPlayerMoveExt.h"
#include "NFCityPlayerQuestExt.h"
#include "NFCityPlayerTeamExt.h"
#include "NFCityPlayerViewExt.h"
#include "NFCityWorldObject.h"
#include "NFComm/NFObjCommon/NFObject.h"
#include "NFComm/NFObjCommon/NFSeqOP.h"
#include "NFLogicCommon/NFCacheStatus.h"
#include "NFLogicCommon/NFLogicShmTypeDefines.h"

class NFCitySession;

class NFCityPlayer : public NF_OBJECT_TEMPLATE_MACRO(NFCityPlayer, EOT_CITY_PLAYER_ID, NFCityWorldObject, public NFSeqOP, public NFCacheStatus)
public:
    NFCityPlayer();
    ~NFCityPlayer() override;
    int CreateInit();
    int ResumeInit();

public:
    int OnTimer(int timeId, int callCount) override;
    int Fini();

public:
    uint64_t StatusId() const override { return m_ullRoleID; }
    bool IsCanLogout() override;
    int DoOnline() override;
    bool IsCanDelete() override;
    int DoLogout() override;
    int LogicTick();
    // 是否检测坐标
    bool IsCheckPos();

public:
    int InitRoleInfo(const proto_ff::CityRoleInfo* pRoleInfo);
    int SynRoleInfo(const proto_ff::CityRoleInfo* pRoleInfo, bool& bNeedRefreshView);

public:
    void SetRoleID(uint64_t ullRoleID) { m_ullRoleID = ullRoleID; }
    uint64_t GetRoleID() const { return m_ullRoleID; }
    NFCitySession* GetClientSession();
    int BindClientSession(NFCitySession* pSession);
    int GetClientSessionID() const { return m_iClientSessionID; }
    uint32_t GetToken() const { return m_iToken; }
    int GetLogicSvrId() const { return m_iLogicSvrId; }
    void SetLogicSvrId(int svrId) { m_iLogicSvrId = svrId; }
    bool IsEnterSvr() const { return m_bEnterSvr; }
    void SetEnterSvr(bool bSet) { m_bEnterSvr = bSet; }
    uint64_t GetGuildID() const { return m_ullGuildID; }
    uint64_t GetGuildBattleID() const { return m_ullGuildBattleID; }
    uint64_t GetDungeonID() const { return m_ullDungeonID; }
    uint64_t GetRaidUUID() const { return m_ullRaidUUID; }
    std::string GetRoleName() const { return m_stRoleBase.name.ToString(); }
    int GetCityHero() const { return m_stHeroOne.id; }
    const RoleMapData* GetMapData() { return m_oMoveExt.GetMapData(); }
    int GetLevel() const { return m_stRoleBase.level; }
    int GetAttrValue(proto_ff::AttrType eType) const;

public:
    int GetTitleID() const { return m_titleID; }
    std::string GetTitleName() const { return m_titleName.ToString(); }
    int GetTitleItemID() const { return m_titleItemID; }
    int GetTitle2ID() const { return m_iTitle2ID; }
    int GetEquipStrengthLevel() const { return m_stHeroOne.equip_strength_level; }
    void SetStateLeave(bool bSet) { m_bStateLeave = bSet; }
    bool IsStateLeave() const { return m_bStateLeave; }

    int GetTransferID() const { return m_iTransferID; }
    int GetFollowPartnerID() const { return m_iFollowPartnerID; }
    bool IsFollowPartnerFatigue() const { return m_bFollowPartnerfatigue; }
    int GetFollowPartnerStar() const { return m_iFollowPartnerStar; }
    int GetWeaponStrengLv() const { return m_iWeaponStrengLv; }
    int MakeFashionData(proto_ff::BattlePlayerHero* pPlayerHero) const;
    int MakeTransExpRole(proto_ff::RoleTransExpData* pExpData) const;
    bool HasTask(int iTaskId) const;
    bool HasNonFinishTask(int iTaskId) const;

public:
    NFCityPlayerMoveExt* GetMoveExt() { return &m_oMoveExt; }
    NFCityPlayerTeamExt* GetTeamExt() { return &m_oTeamExt; }
    NFCityPlayerEscortAgent* GetEscortAgent() { return &m_oPlayerEscortAgent; }
    NFCityPlayerBattleExt* GetBattleExt() { return &m_oBattleExt; }
    NFCityPlayerViewExt* GetViewList() { return &m_oViewExt; }
    NFCityPlayerBuffExt* GetBuffExt() { return &m_oBuffExt; }
    NFCityPlayerDanceExt* GetDanceExt() { return &m_oDanceExt; }

public:
    int UpdateMapData(int iMapDescID, const Proto_Vector3& oPos, int iDirection) override;
    int SynMapData() override;
public:
    int OnEnterMap(int iMapInstId, int iMapDescId) override;
private:
    bool IsNeedSyn() { return GetCurSeq() > m_iCurSynSeq; }

private:
    uint64_t m_ullRoleID;
    int m_iClientSessionID;
    NFCitySession* m_pClientSession;

    RoleBase m_stRoleBase;
    HeroOne m_stHeroOne;

    bool m_bIsInit;
    bool m_bEnterSvr;

    uint32_t m_iToken;
    bool m_bStateLeave;

private:
    NFCityPlayerMoveExt m_oMoveExt;
    NFCityPlayerQuestExt m_oQuestExt;
    NFCityPlayerTeamExt m_oTeamExt;
    NFCityPlayerBattleExt m_oBattleExt;
    NFCityPlayerBuffExt m_oBuffExt;
    NFCityPlayerDanceExt m_oDanceExt;
    NFCityPlayerViewExt m_oViewExt;
    NFCityPlayerEscortAgent m_oPlayerEscortAgent;

private:
    int m_fashions[proto_ff::enFashionType_MAX];
    uint64_t m_familyCallerID;
    uint64_t m_transExpRole;
    bool m_isPrepare;
    int32_t m_iTransferID;

private:
    int32_t m_iFollowPartnerID;
    bool m_bFollowPartnerfatigue;
    int32_t m_iFollowPartnerStar;

private:
    uint64_t m_ullGuildID;
    uint64_t m_ullGuildBattleID;
    uint64_t m_ullDungeonID;
    uint64_t m_ullRaidUUID;
    int m_titleID;
    NFShmString<64> m_titleName;
    uint32_t m_titleItemID;
    int m_iTitle2ID;
    int m_iWeaponStrengLv;

private:
    uint32_t m_iCurSynSeq;

private:
    int m_iLogicSvrId;
};
